<{include file="public/header.html"}>
		<script type="text/javascript" src="<{STATIC_SERVER}>/home/js/SuggestServer_3_0_16.js"></script>
		<div class="my-pic">
			<span>交易</span>
		</div>
		<div class="xinsu-section" style="padding-top: 43px;">
			<div class="xinsu-deal">
				<form class="weui-cells xinsu-cells" method="post">
					<div class="weui-cell">
						<div class="weui-cell__bd">
							<p>可用额度：<span class="xinsu-color-red">￥<{number_format($user.amount, 2)}></span></p>
						</div>
					</div>
					<div class="weui-cell xinsu-cell">
						<div class="weui-cell__fl">
							<label class="weui-label">证券代码：</label>
						</div>
						<div class="weui-cell__bd">
							<input type="text" name="stock_code" id="stock_code"class="weui-input" placeholder="代码/名称/拼音" <{if $common_info.holiday == "休市" || $user.amount <= 0}>disabled<{else}>onBlur="get_stock();"<{/if}> />
						</div>
					</div>
					<div class="weui-cell xinsu-cell">
						<div class="weui-cell__fl">
							<label class="weui-label">证券名称：</label>
						</div>
						<div class="weui-cell__bd">
							<input type="text" name="stock_name" id="stock_name" class="weui-input xinsu-color-red" disabled>
						</div>
					</div>
					<div class="weui-cell xinsu-cell">
						<div class="weui-cell__fl">
							<label class="weui-label">当前价格：</label>
						</div>
						<div class="weui-cell__bd">
							<input type="text" name="stock_price" id="stock_price" class="weui-input xinsu-color-green" disabled>
						</div>
					</div>
					<div class="weui-cell xinsu-cell">
						<div class="weui-cell__fl">
							<label class="weui-label">证券类型：</label>
						</div>
						<div class="weui-cell__bd">
							<input type="radio" name="bull_type" value="1" checked <{if $common_info.holiday == "休市" || $user.amount <= 0}>disabled<{/if}>>
							<span class="xinsu-color-red">融资</span>
							<input type="radio" name="bull_type" value="2" <{if $common_info.holiday == "休市" || $user.amount <= 0}>disabled<{/if}>>
							<span class="xinsu-color-green">融券</span>
						</div>
					</div>
					<div class="weui-cell xinsu-cell">
						<div class="weui-cell__fl">
							<label class="weui-label">买入价格：</label>
						</div>
						<div class="weui-cell__bd">
							<input type="radio" name="price_type" value="0" checked <{if $common_info.holiday == "休市" || $user.amount <= 0}>disabled<{/if}>>
							<span class="xinsu-color-red">市价</span>
							<input type="radio" name="price_type" value="1" <{if $common_info.holiday == "休市" || $user.amount <= 0}>disabled<{/if}>>
							<span class="xinsu-color-green">委托价</span>
						</div>
					</div>
					<div class="weui-cell xinsu-cell" style="display:none;" id="xinsu-price-type">
						<div class="weui-cell__fl">
							<label class="weui-label">委托价格：</label>
						</div>
						<div class="weui-cell__bd">
							<input type="text" name="bull_price" class="weui-input xinsu-color-red" id="bull_price" placeholder="请输入委托价格">
						</div>
					</div>
					<div class="weui-cell xinsu-cell">
						<div class="weui-cell__fl">
							<label class="weui-label">可买股：</label>
						</div>
						<div class="weui-cell__bd">
							<input type="text" name="num" id="num" class="weui-input" disabled>
							<button class="weui-btn xinsu-btn1 weui-btn_primary xinsu-btn-buy" type="button" <{if $common_info.holiday == "休市" || $user.amount <= 0}>disabled<{else}>onclick="bull_all()"<{/if}>>全部</button>
						</div>
					</div>
					<div class="weui-cell xinsu-cell">
						<div class="weui-cell__fl">
							<label class="weui-label">可买数量：</label>
						</div>
						<div class="weui-cell__bd">
							<input type="text" name="bull_num" id="bull_num" class="weui-input" <{if $common_info.holiday == "休市" || $user.amount <= 0}><{/if}>>
						</div>
					</div>
					<div class="xinsu-deal-data">
					<div class="weui-flex">
					  	<div class="weui-flex__item">卖5</div>
					  	<div class="weui-flex__item"><span class="xinsu-color-green" id="xinsu-sell-50">--</span></div>
					  	<div class="weui-flex__item" id="xinsu-sell-51">--</div>
					  	<div class="weui-flex__item">买5</div>
					  	<div class="weui-flex__item"><span class="xinsu-color-red" id="xinsu-bull-50">--</span></div>
					  	<div class="weui-flex__item" id="xinsu-bull-51">--</div>
					</div>
					<div class="weui-flex">
						<div class="weui-flex__item">卖4</div>
					  	<div class="weui-flex__item"><span class="xinsu-color-green" id="xinsu-sell-40">--</span></div>
					  	<div class="weui-flex__item" id="xinsu-sell-41">--</div>
					  	<div class="weui-flex__item">买4</div>
					  	<div class="weui-flex__item"><span class="xinsu-color-red" id="xinsu-bull-40">--</span></div>
					  	<div class="weui-flex__item" id="xinsu-bull-41">--</div>
					</div>
					<div class="weui-flex">
						<div class="weui-flex__item">卖3</div>
					  	<div class="weui-flex__item"><span class="xinsu-color-green" id="xinsu-sell-30">--</span></div>
					  	<div class="weui-flex__item" id="xinsu-sell-31">--</div>
					  	<div class="weui-flex__item">买3</div>
					  	<div class="weui-flex__item"><span class="xinsu-color-red" id="xinsu-bull-30">--</span></div>
					  	<div class="weui-flex__item" id="xinsu-bull-31">--</div>
					</div>
					<div class="weui-flex">
						<div class="weui-flex__item">卖2</div>
					  	<div class="weui-flex__item"><span class="xinsu-color-green" id="xinsu-sell-20">--</span></div>
					  	<div class="weui-flex__item" id="xinsu-sell-21">--</div>
					  	<div class="weui-flex__item">买2</div>
					  	<div class="weui-flex__item"><span class="xinsu-color-red" id="xinsu-bull-20">--</span></div>
					  	<div class="weui-flex__item" id="xinsu-bull-21">--</div>
					</div>
					<div class="weui-flex">
						<div class="weui-flex__item">卖1</div>
					  	<div class="weui-flex__item"><span class="xinsu-color-green" id="xinsu-sell-10">--</span></div>
					  	<div class="weui-flex__item" id="xinsu-sell-11">--</div>
					  	<div class="weui-flex__item">买1</div>
					  	<div class="weui-flex__item"><span class="xinsu-color-red" id="xinsu-bull-10">--</span></div>
					  	<div class="weui-flex__item" id="xinsu-bull-11">--</div>
					</div>
					<div class="weui-flex xinsu-flex">
					  	<div class="weui-flex__item">现价：<span class="xinsu-color-red" id="xinsu-now-price">--</span></div>
					  	<div class="weui-flex__item">昨收：<span class="xinsu-color-green" id="xinsu-yesterday-price">--</span></div>
					</div>
					<div class="weui-flex">
					  	<div class="weui-flex__item">最高价：<span class="xinsu-color-red" id="xinsu-bull-price">--</span></div>
					  	<div class="weui-flex__item">最低价：<span class="xinsu-color-green" id="xinsu-sell-price">--</span></div>
					</div>
					</div>
					<div class="weui-btn-area xinsu-btn-area">
						<button class="weui-btn xinsu-btn weui-btn_primary" type="submit">下单</button>
					</div>
				</form>
			</div>
		</div>
		<{if $common_info.holiday != "休市" || $user.amount <= 0}>
		<script>
			$(function(){
				//股票查询事件
				var suggestServer = new SuggestServer();
				suggestServer.bind({
					"input": "stock_code",
					"value": "@2@",
					"type": "",
					"max": 10,
					"width": 250,
					"head": ["选项", "代码", "中文名称"],
					"body": [-1, 2, 4],
					"fix": { "ie6" : [0, - 1], "ie7" : [0, - 1], "firefox" : [1, 1]},
					"callback": function(){
						stock = 0;
						get_stock();
					}
				});
			})
			var amount = "<{$user.amount}>";
			var stock = 0;
			
			//市价，委托价选择
			$("input[name='price_type']").click(function(){
				var price_type = $('input[name="price_type"]:checked').val();
				if (price_type == 0) {
					$("#xinsu-price-type").hide();
				} else {
					$("#xinsu-price-type").show();
					$("#bull_price").val($("#stock_price").val());
				}
			})
			
			//股票信息
			function get_stock() {
				var code = $('#stock_code').val();
				if(code.length == 6 && stock >= 0) {
					http_request_post("/stock/ajax_get_stock", {code : code}, function(result) {
						var data = result.data;
						//卖五
						$("#xinsu-sell-50").html(data[29]);
						$("#xinsu-sell-51").html(data[28]);
						//卖四
						$("#xinsu-sell-40").html(data[27]);
						$("#xinsu-sell-41").html(data[26]);
						//卖三
						$("#xinsu-sell-30").html(data[25]);
						$("#xinsu-sell-31").html(data[24]);
						//卖二
						$("#xinsu-sell-20").html(data[23]);
						$("#xinsu-sell-21").html(data[22]);
						//卖一
						$("#xinsu-sell-10").html(data[21]);
						$("#xinsu-sell-11").html(data[20]);
						
						//买一
						$("#xinsu-bull-10").html(data[19]);
						$("#xinsu-bull-11").html(data[18]);
						//买二
						$("#xinsu-bull-20").html(data[17]);
						$("#xinsu-bull-21").html(data[16]);
						//买三
						$("#xinsu-bull-30").html(data[15]);
						$("#xinsu-bull-31").html(data[14]);
						//买四
						$("#xinsu-bull-40").html(data[13]);
						$("#xinsu-bull-41").html(data[12]);
						//买五
						$("#xinsu-bull-50").html(data[11]);
						$("#xinsu-bull-51").html(data[10]);
						
						//价格
						$("#xinsu-now-price").html(data[3]);
						$("#xinsu-yesterday-price").html(data[2]);
						
						//涨停
						$("#xinsu-bull-price").html(data[4]);
						$("#xinsu-sell-price").html(data[5]);
						
						//股票信息
						$("#stock_name").val(data[0]);
						$("#stock_price").val(data[3]);

						//可买股数
						if (Math.floor(amount / data[3]) <= 0) {
							var num = 0;
						} else {
							var num = Math.floor(amount / data[3]);
						}
						$("#num").val(num);
					})
					
					stock = setTimeout("get_stock();", 1500);
				}
			}
			
			//全部买入
			function bull_all() {
				var bull_num = $("#num").val();
				$("#bull_num").val(bull_num);
			}
		</script>
		<{/if}>
<{include file="public/footer.html"}>